﻿using System;
using System.Data;
using DotNetNuke;

namespace CharityGamesOnline.Modules.Game
{
    /// ----------------------------------------------------------------------------- 
    /// <summary> 
    /// An abstract class for the data access layer 
    /// </summary> 
    /// <remarks> 
    /// </remarks> 
    /// <history> 
    /// </history> 
    /// ----------------------------------------------------------------------------- 
    public abstract class DataProvider
    {

        #region "Shared/Static Methods"

        /// <summary>
        /// singleton reference to the instantiated object 
        /// </summary>
        private static DataProvider objProvider = null;

        /// <summary>
        /// constructor
        /// </summary>
        static DataProvider()
        {
            CreateProvider();
        }

        /// <summary>
        /// dynamically create provider 
        /// </summary>
        private static void CreateProvider()
        {
            objProvider = (DataProvider)DotNetNuke.Framework.Reflection.CreateObject("data", "CharityGamesOnline.Modules.Game", "");
        }

        /// <summary>
        /// return the provider 
        /// </summary>
        /// <returns></returns>
        public static DataProvider Instance()
        {
            return objProvider;
        }

        #endregion

        #region "Game Abstract methods"
        
        public abstract IDataReader GetGame(int gameID);
        public abstract IDataReader GetGames(int portalID, int eventID);
        public abstract void SaveGame(int gameID, int portalID, int userID, int status, string name, string description,
                                      string imageURL, string imageType, int imageWidth, int imageHeight, 
                                      int gameTabID, int category, bool imageDisplay);
        public abstract void DeleteGame(int gameID);

        public abstract IDataReader GetGamePackages();
        public abstract IDataReader GetGamePackage(int packageID);
        #endregion

        #region "GameEnrollment Abstract Methods"
        public abstract IDataReader GetEnrollment(int portalID, int enrollmentID);
        public abstract IDataReader GetEnrollments(int portalID, int eventID, int gameID, int userID, int enrollStatusID, bool getCount, int pageSize, int currentPage);
        public abstract IDataReader GetEnrollmentsByUser(int portalID, int userID, bool getCount, int pageSize, int currentPage);
        public abstract int SaveEnrollment(int enrollmentID,int portalID, int eventID, int gameID, int userID, int enrollStatusID,
                                            decimal enrollFee, DateTime startTime, DateTime endTime, int connectCount, decimal score);
        public abstract void DeleteEnrollment(int portalID, int enrollmentID);

        public abstract int GetPlayedCount(int portalID, int eventID, int gameID, int userID, int enrollStatusID);
        public abstract decimal GetMoneyCount(int portalID, int eventID, int gameID, int userID, int enrollStatusID);
        public abstract int GetUserRank(int enrollID, int userID);
        #endregion
    }
}
